home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / postgres / postgre3.z / postgre3 / src / lib / H / access / attnum.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-27  |  2.2 KB  |  74 lines

  1. /* ----------------------------------------------------------------
  2.  *   FILE
  3.  *    attnum.h
  4.  *
  5.  *   DESCRIPTION
  6.  *    POSTGRES attribute number definitions.
  7.  *
  8.  *   IDENTIFICATION
  9.  *    $Header: /private/postgres/src/lib/H/access/RCS/attnum.h,v 1.10 1991/05/01 02:49:54 cimarron Exp $
  10.  * ----------------------------------------------------------------
  11.  */
  12. #ifndef    AttNumIncluded        /* Include this file only once */
  13. #define AttNumIncluded    1
  14.  
  15. #define ATTNUM_H    "$Header: /private/postgres/src/lib/H/access/RCS/attnum.h,v 1.10 1991/05/01 02:49:54 cimarron Exp $"
  16.  
  17. #include "tmp/c.h"
  18.  
  19. typedef int16        AttributeNumber;
  20. typedef AttributeNumber    *AttributeNumberPtr;
  21. typedef uint16        AttributeOffset;
  22.  
  23. #define InvalidAttributeNumber    0
  24.  
  25. /* ----------------
  26.  *    support macros
  27.  * ----------------
  28.  */
  29. /*
  30.  * AttributeNumberIsValid --
  31.  *    True iff the attribute number is valid.
  32.  */
  33. #define AttributeNumberIsValid(attributeNumber) \
  34.     ((bool) ((attributeNumber) != InvalidAttributeNumber))
  35.  
  36. /*
  37.  * AttributeNumberIsForUserDefinedAttribute --
  38.  *    True iff the attribute number corresponds to an user defined attribute.
  39.  */
  40. #define AttributeNumberIsForUserDefinedAttribute(attributeNumber) \
  41.     ((bool) ((attributeNumber) > 0))
  42.  
  43. /*
  44.  * AttributeNumberIsInBounds --
  45.  *    True iff attribute number is within given bounds.
  46.  *
  47.  * Note:
  48.  *    Assumes AttributeNumber is an signed type.
  49.  *    Assumes the bounded interval to be (minumum,maximum].
  50.  *    An invalid attribute number is within given bounds.
  51.  */
  52. #define AttributeNumberIsInBounds(attNum, minAttNum, maxAttNum) \
  53.      ((bool) OffsetIsInBounds(attNum, minAttNum, maxAttNum))
  54.  
  55. /*
  56.  * AttributeNumberGetAttributeOffset --
  57.  *    Returns the attribute offset for an attribute number.
  58.  *
  59.  * Note:
  60.  *    Assumes the attribute number is for an user defined attribute.
  61.  */
  62. #define AttributeNumberGetAttributeOffset(attNum) \
  63.      (AssertMacro(AttributeNumberIsForUserDefinedAttribute(attNum)) ? \
  64.       ((AttributeOffset) (attNum - 1)) : (AttributeOffset) 0)
  65.  
  66. /*
  67.  * AttributeOffsetGetAttributeNumber --
  68.  *    Returns the attribute number for an attribute offset.
  69.  */
  70. #define AttributeOffsetGetAttributeNumber(attributeOffset) \
  71.      ((AttributeNumber) (1 + attributeOffset))
  72.  
  73. #endif    /* !defined(AttNumIncluded) */
  74.